﻿$(function () {
    $('.test-row').each(function (row) {

        var expectedValue = $(this).find('.expected').text();
        var rewrittenValue = $(this).find('.rewrittenValue').attr('href');

        $(this).find('.rewritten').text(rewrittenValue);

        if (rewrittenValue.caseInsensitiveCompare(expectedValue)) {
            $(this).addClass('success');
            $(this).find('.status').text('Pass');

        } else {
            $(this).addClass('danger');
            $(this).find('.status').text('Fail');
        }
    });
});

String.prototype.caseInsensitiveCompare = function (str) {
    str = str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&").trim();
    var r = new RegExp('^' + str + '$', 'i');
    return r.test(this.trim());
}

